package com.masterclient.app.modules.search.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.masterclient.app.R;
import com.masterclient.app.modules.search.SearchGoodBean;

import java.util.List;

/**
 * 作者：sean
 * 创建时间：2017/6/27 07:15
 * 功能说明：搜索结果侧滑筛选条件中的类别筛选
 */

public class CateGridAdapter extends BaseAdapter{

    public void setList(List<SearchGoodBean.DataBean.ShCategorysBean> list) {
        this.list = list;
        notifyDataSetChanged();
    }

    public void isShow(boolean isShow){
        this.isShow = isShow;
        notifyDataSetChanged();
    }

    private List<SearchGoodBean.DataBean.ShCategorysBean> list;
    private boolean isShow;
    private Context context;
    public CateGridAdapter(Context context) {
        this.context = context;
        isShow = true;
    }

    @Override
    public int getCount() {
        return list == null?0:isShow?list.size():3;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        SearchGoodBean.DataBean.ShCategorysBean cateBean = list.get(position);
        TextView tv = (TextView) View.inflate(context, R.layout.text_condition,null);
        tv.setText(cateBean.getSh_name());
        if(cateBean.isCheck()){
            tv.setBackgroundResource(R.drawable.bg_rect_buy_black);
            tv.setTextColor(Color.parseColor("#ffffff"));
        }else {
            tv.setBackgroundResource(R.drawable.bg_rect_tag_black);
            tv.setTextColor(Color.parseColor("#333333"));
        }
        return tv;
    }
}
